#include "stdafx.h"
#include "ForceEntity.h"
#include "Kingdom.h"

sgObject * sgForceEntity::Creator()
{
    return new sgForceEntity;
}

bool sgForceEntity::m_creatorRegisted = CObjectManager::Instance().RegisteCreator(OBJ_FORCEENTITY, sgForceEntity::Creator );


sgForceEntity::sgForceEntity( int type /*= 0 */ )
{
    m_owner = NULL;
}

sgForceEntity::~sgForceEntity()
{

}

bool sgForceEntity::Initialize()
{
    return true;
}

void sgForceEntity::SetOwner( sgKingdom *owner )
{
    m_owner = owner;
}

sgKingdom * sgForceEntity::GetOwner()
{
    return m_owner;
}

void sgForceEntity::Serialize( CSerialize& s )
{
    sgEntity::Serialize(s);
    if( s.IsSaving() )
    {
        CHECK_PTR_VOID(m_owner);
    }
    int ownerid = -1;
    if( s.IsSaving() )
        ownerid = m_owner->GetID();
    s&MAKE_PAIR(ownerid,"owner");
    if( s.IsLoading() )
    {
        m_owner = (sgKingdom *)CObjectManager::Instance().GetObject( ownerid );
    }
}
